package io.renren.modules.order_pay.service.impl;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.member.service.V9MemberService;
import io.renren.modules.order_pay.dao.V9OrderPayDao;
import io.renren.modules.order_pay.entity.V9OrderPayEntity;
import io.renren.modules.order_pay.entity.VO.V9OrderPayVO;
import io.renren.modules.order_pay.service.V9OrderPayService;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("v9OrderPayService")
public class V9OrderPayServiceImpl extends ServiceImpl<V9OrderPayDao, V9OrderPayEntity> implements V9OrderPayService {

    @Autowired
    private V9OrderPayDao v9OrderPayDao;

    @Autowired
    V9MemberService v9MemberService;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String listid = (String)params.get("listid");
        String user_id = (String)params.get("user_id");
        String pay_status = (String)params.get("pay_status");
        String username = (String)params.get("username");
        String payment = (String)params.get("payment");
        String start = (String)params.get("start");
        String end = (String)params.get("end");
        Integer pages = Integer.parseInt(params.get("page").toString());
        Integer limit = Integer.parseInt(params.get("limit").toString());
        Integer status=null;
        Integer status1=null;
        if (StringUtils.isNotBlank(pay_status)) {
            status=Integer.parseInt(pay_status);
        }

        int page = (pages -1)*limit;
        params.put("page",page);
        params.put("limit",limit);
        List<V9OrderPayVO> list = v9OrderPayDao.selectOrderPay(params);
        int count = v9OrderPayDao.selectOrderPayCount(params);
        Page<V9OrderPayVO> page1 = new Page<>(pages,limit);
        page1.setRecords(list);
        page1.setTotal(count);
        page1.setCurrent(pages);
        page1.setSize(limit);
        return new PageUtils(page1);
    }
    @Override
    public Integer insertSelective(V9OrderPayEntity v9OrderPayEntity) {
        baseMapper.insert(v9OrderPayEntity);
        return v9OrderPayEntity.getPayId();
    }

    @Override
    public R getYunFei() {
        return v9OrderPayDao.getYunFei();
    }

}
